package com.uuyun.preview.service.impl;

import com.uuyun.preview.mappers.UsersMapper;
import com.uuyun.preview.entity.Result;
import com.uuyun.preview.entity.Users;
import com.uuyun.preview.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import static com.uuyun.preview.responseData.EnumErrorCode.ERROR_REQUEST_FIELD;
import static com.uuyun.preview.responseData.EnumErrorCode.NO_EXIST_USER;

@Service
public class UserServiceImpl implements IUserService {

    @Resource
    UsersMapper usersMapper;

    @Override
    public Result getUser(Integer UserId) {
        if (UserId == null) {
            return Result.error(ERROR_REQUEST_FIELD);
        }
        Users user = usersMapper.getUser(UserId);
        if (user == null) {
            return Result.error(NO_EXIST_USER);
        }
        return Result.success("", user);
    }

}
